<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <!-- 1. 引入 -->
    <script src="../js/template-web.js"></script>
    <!-- <script src="G:\三次元\2-学习\11-web\11-AJax\ajax_note\public\js"></script> -->
  </head>

  <body>
    <div id="container"></div>
    <!-- 2. 准备模板 -->
    <script type="text/html" id="tpl">
      <!-- a1 -->
      {{each data}}
      <h1>{{$value}}</h1>
      {{/each}}
    </script>

    <!-- 3. 告诉模板引擎将哪一个模板和哪个数据进行拼接 -->
    <script>
      var data = [
        {
          username: 'zhangsam',
          age: 20
        },
        {
          username: 'zhangsam',
          age: 20
        },
        {
          username: 'zhangsam',
          age: 20
        },
        {
          username: 'zhangsam',
          age: 20
        }
      ]
      // a1
      var att = ['123', '4213', '12314']
      var html = template('tpl', { data: att })
      console.log(html)
      document.getElementById('container').innerHTML = html
    </script>
  </body>
</html>
